|
|
|
|
|
|
|
Unloading the Form on an Error |
|
|
|
|
|
|
|
|
If the user receives an error when the data control is loading at runtime, theres no reason to bring up the form. As such, lets add code so that the form will unload if an error occurs. Remember the mboolLoadError flag you set in the DCErrorCheck() procedure? You can use this in the Form_Activate() event to determine whether an error occurred when the data control was loading. Because the Form_Activate() event is the last event to occur after a form loads, the mboolLoadError variable will be set to True if an error has occurred. If this flag is set, you might as well unload the form. |
|
|
|
|
| Write the Form_Activate() Event 1. Add the following code to the Form_Activate() event: | | Private Sub Form_Activate()
If mboolLoadError Then
Unload Me
End If
End Sub |
|
|
|
|
|
|
Programming the data controls Recordset object will help you make a nicer user interface than just the normal data control. Using just a few properties and some code, you can make a complete add, edit, and delete data entry form. Error handling and data validation are important to any data entry form, and you learned how to accomplish these techniques by using the many events of the data control. Adding a Find method can add a nice finishing touch to your data entry form. |
|
|
|
|
|
|
|
|
1. Which event do you use to perform data validation? |
|
|
|
|
|
|
|
|
2. Which event reports back errors from the data control to your form? |
|
|
|
|
|
|
|
|
3. Which property can you use to report the current record position? |
|
|
|
|
|
|
|
|
4. Which method do you use to search for a particular record in the recordset? |
|
|
|
|
|